import { createStore } from 'vuex'
export default createStore({

  //定义需要管理的数组、对象、字符
  state: {
    playlist:{
    },
    name:'网易云',
    al:{},
    tracks:{},
    id:'',
    playCurrentIndex:0,
  },

  //这里是的方法可修改state的值
  mutations: {
    // 获取playList
    setPlayList(state,value){
      state.playlist = value
      // 歌曲名字
      state.name = state.playlist.tracks[state.playCurrentIndex].name
      state.al = state.playlist.tracks[state.playCurrentIndex].al
      // 歌曲id
      state.id = state.playlist.tracks[state.playCurrentIndex].id
      console.log(state.id);
     
    },
    // 获取playIndex
    setPlayIndex(state,value){
      state.playCurrentIndex = value
      state.id = state.playlist.tracks[state.playCurrentIndex].id
      state.name = state.playlist.tracks[state.playCurrentIndex].name
    }
  },

  actions: {
    
  },
  modules: {
  },
})
